/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package action.news;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import javax.servlet.http.HttpServletRequest;
import myUtils.page.Page;
import myUtils.page.Result;
import org.apache.struts2.interceptor.ServletRequestAware;
import service.NewsService;

/**
 *
 * @author sony
 */
public class AllNewsListAction extends ActionSupport implements ServletRequestAware {

    private HttpServletRequest request;
    private NewsService newsService;

    @Override
    public String execute() {
        int page = request.getParameter("page") == null ? 1 : Integer.parseInt((String) request.getParameter("page"));

        Result result = newsService.getAllNews(page);
        request.setAttribute("result", result);
        return SUCCESS;
    }

    public void setServletRequest(HttpServletRequest arg0) {
        this.request = arg0;
    }

    public NewsService getNewsService() {
        return newsService;
    }

    public void setNewsService(NewsService newsService) {
        this.newsService = newsService;
    }

}
